/** 
系统用户
 **/
package com.cd2cd.code_template.controller;

import com.cd2cd.code_template.configuration.authority.AuthControl;
import com.cd2cd.code_template.configuration.constants.AuthTypeEnum;
import com.cd2cd.code_template.service.SysUserService;
import com.cd2cd.code_template.vo.BaseRes;
import com.cd2cd.code_template.vo.PageData;
import com.cd2cd.code_template.vo.SysUserVo;
import javax.annotation.Resource;
import javax.annotation.Title;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("sys-user")
@AuthControl(name = "用户管理",type = AuthTypeEnum.Backend,routePath = "/system-user/page")
public class SysUserController {


    @Resource
    private SysUserService sysUserService;

    /**
     * @gen_901_lwl
     * 用户列表
     * 用户列表
     * @param sysUserVo
    **/
    @Title("用户列表")
    @ResponseBody
    @RequestMapping(value="list", method=RequestMethod.GET)
    public BaseRes<PageData<SysUserVo>> getUserList(SysUserVo sysUserVo) {
        return sysUserService.getUserList(sysUserVo);
    }

    /**
     * @gen_902_lwl
     * 添加用户
     * 添加用户
     * @param sysUserVo
    **/
    @Title("添加用户")
    @ResponseBody
    @RequestMapping(value="info", method=RequestMethod.POST)
    public BaseRes<String> addUser(@RequestBody SysUserVo sysUserVo, BindingResult bindingResult) {
        return sysUserService.addUser(sysUserVo);
    }

    /**
     * @gen_903_lwl
     * 修改用户
     * 修改用户
     * @param sysUserVo
    **/
    @Title("修改用户")
    @ResponseBody
    @RequestMapping(value="info", method=RequestMethod.PUT)
    public BaseRes<String> updateUser(@RequestBody SysUserVo sysUserVo, BindingResult bindingResult) {
        return sysUserService.updateUser(sysUserVo);
    }

    /**
     * @gen_904_lwl
     * 删除用户
     * 删除用户
     * @param sysUserVo
    **/
    @Title("删除用户")
    @ResponseBody
    @RequestMapping(value="info", method=RequestMethod.DELETE)
    public BaseRes<String> delUser(@RequestBody SysUserVo sysUserVo, BindingResult bindingResult) {
        return sysUserService.delUser(sysUserVo);
    }

    /**
     * @gen_905_lwl
     * 用户详情
     * 用户详情
     * @param sysUserVo
    **/
    @Title("用户详情")
    @ResponseBody
    @RequestMapping(value="info", method=RequestMethod.GET)
    public BaseRes<SysUserVo> userDetail(SysUserVo sysUserVo) {
        return sysUserService.userDetail(sysUserVo);
    }
}